package com.servlet.yanglaoyuan.mapper;

import com.servlet.yanglaoyuan.pojo.Health_Checkup_Data;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface Health_Checkup_DataMapper {
    /**
     * 添加一条体检数据
     */
    @Insert("insert into health_checkup_data(elderly_id,date,systolic,diastolic,blood_sugar,weight,temperature,heart_rate,notes) " +
    "values(#{elderlyId},#{date},#{systolic},#{diastolic},#{bloodSugar},#{weight},#{temperature},#{heartRate},#{notes})")
    public void add(Health_Checkup_Data health_checkup_data);

    /**
     * 修改一条体检数据
     */
    public void updateCheckupData(Health_Checkup_Data health_checkup_data);
    /**
     * 根据id查询一条体检数据
     */
    @Select("select * from health_checkup_data where id= #{id}")
    public Health_Checkup_Data getById(Integer id);

    /**
     * 根据id删除一条体检数据
     */
    @Insert("delete from health_checkup_data where id= #{id}")
    public void deleteCheckupData(Integer id);
    /**
     * 查询出所有的体检数据
     */
    @Select("select * from health_checkup_data")
    public List<Health_Checkup_Data> getAll();
    /**
     * 根据elderly_id查询出所有的体检数据
     */
    @Select("select * from health_checkup_data where elderly_id= #{elderly_id}")
    public List<Health_Checkup_Data> getByElderlyId(Integer elderly_id);
    /**
     * 根据时间查询出所有的体检数据
     */
    @Select("select * from health_checkup_data where date between #{startDate} and #{endDate}")
    public List<Health_Checkup_Data> getByDate(LocalDateTime startDate, LocalDateTime endDate);
}
